package com.guashu.jaywayjsonpath.web;


import com.jayway.jsonpath.JsonPath;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;

@RestController
@RequestMapping("/")
public class RenHangController {


    @GetMapping("insertData")
    public void list(){
        int i=1000;
        for( i=1;i<10000;i++){
            System.out.println("你好，我是特工"+i+"号");
        }

    }

    @GetMapping("/example")
    public String useCustomFunction() throws IOException {
        // 示例 JSON 数据
        String jsonFilePath = "E:\\国银租赁\\需求\\20240201-人行指标\\人行报文.json"; // JSON文件路径
        String jsonStr = new String(Files.readAllBytes(Paths.get(jsonFilePath)), StandardCharsets.UTF_8);
        String result = JsonPath.parse(jsonStr).read("$.PPO.PC04.PC040H[?(@.PC040D01 == '1')].PC040D01.arrayToString()");
        return result;
    }

}
